import static org.junit.Assert.*;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

/**
 * 
 */

/**
 * @author Joseph
 *
 */
public class VendingMachineItemTest {
	VendingMachineItem chips, soda;

	/**
	 * @throws java.lang.Exception
	 */
	@Before
	public void setUp() throws Exception {
		soda = new VendingMachineItem( "soda", 1.00 );
	}

	/**
	 * @throws java.lang.Exception
	 */
	@After
	public void tearDown() throws Exception {
	}

	/**
	 * Test method for {@link VendingMachineItem#VendingMachineItem(java.lang.String, double)}.
	 * testing that we can create a valid vending machine item
	 */
	@Test
	public void testVendingMachineItemConstructorValidInput() {
		chips = new VendingMachineItem( "chips", 1.25 );
	}

	/**
	 * Test method for {@link VendingMachineItem#VendingMachineItem(java.lang.String, double)}.
	 * testing that we can create an item with price zero "0"
	 */
	@Test
	public void testVendingMachineItemConstructorPriceZero() {
		chips = new VendingMachineItem( "chips", 0 );
	}

	/**
	 * Test method for {@link VendingMachineItem#VendingMachineItem(java.lang.String, double)}.
	 * testing that an invalid item throws a VendingMachineException
	 */
	@Test ( expected = VendingMachineException . class )
	public void testVendingMachineItemConstructorVendingMachineExceptionPrice() {
		chips = new VendingMachineItem( "chips", -1.25 );
	}

	/**
	 * Test method for {@link VendingMachineItem#VendingMachineItem(java.lang.String, double)}.
	 * testing that an item with an empty name throws error
	 */
	@Test ( expected = VendingMachineException . class )
	public void testVendingMachineItemConstructorVendingMachineExceptionName() {
		chips = new VendingMachineItem( "", 10 );
	}

	/**
	 * Test method for {@link VendingMachineItem#getName()}.
	 * testing that the name is correct
	 */
	@Test
	public void testGetName() {
		assertEquals("soda", soda.getName());
	}

	/**
	 * Test method for {@link VendingMachineItem#getPrice()}.
	 * testing that the price is correct
	 */
	@Test
	public void testGetPrice() {
		assertEquals(1.00, soda.getPrice(), 0);
	}

}
